﻿@model dynamic

@{
    int pageSize = 10;
    int totalCount = Model.TotalCount != null ? Model.TotalCount : 0;
    int currentPage = Model.CurrentPage != null ? Model.CurrentPage : 1;
    int totalPages = (int)Math.Ceiling((double)totalCount / pageSize);
}

<style>
    .pagination {
        display: flex;
        justify-content: center; 
        list-style-type: none; 
        padding: 0;
        margin: 20px 0;
    }

        .pagination li {
            margin: 0 5px; 
        }

        .pagination a {
            display: block;
            padding: 10px 15px; 
            border: 1px solid #007bff; 
            border-radius: 5px; 
            color: #007bff; 
            text-decoration: none; 
            transition: background 0.3s, color 0.3s; 
        }

            .pagination a:hover {
                background: #007bff; 
                color: white; 
            }

        .pagination .active a {
            background: #007bff; 
            color: white; 
            pointer-events: none; 
        }
</style>

<nav aria-label="Page navigation">
    <ul class="pagination">
        @for (int i = 1; i <= totalPages; i++)
        {
            <li class="@(i == currentPage ? "active" : "")">
                <a asp-action="Index" asp-route-pageNumber="@i" asp-route-productName="@ViewData["CurrentFilter"]">@i</a>
            </li>
        }
    </ul>
</nav>